﻿@{
    Layout = null;
}
@model Freshbox2._0.MODEL.customer
<!DOCTYPE html>

<html>
<head>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/gif" href="~/img/animated_favicon1.gif">
    <meta name="viewport" content="width=device-width" />
    <link href="~/UILibs/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/UILibs/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Css/css.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/UILibs/easyui/jquery.easyui.min.js"></script>
    <script src="~/UILibs/easyui/locale/easyui-lang-zh_CN.js"></script>

    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
    <title></title>
    <script type="text/javascript">
        //时间格式化 转化为 yyyy
        function format(str) {
            if (str != null) {
                var d = eval('new ' + str.substr(1, str.length - 2));
                var ar_date = [d.getFullYear(), d.getMonth() + 1, d.getDate()];
                for (var i = 0; i < ar_date.length; i++) ar_date[i] = dFormat(ar_date[i]);
                return ar_date.join('-');
                function dFormat(i) { return i < 10 ? "0" + i.toString() : i; }
            }
            else {
                return null;
            }
        }

        $(function () {
            $("#data").datagrid({
                fit: true,
                title: '大客户信息统计',
                striped: true,
                rownumbers: true,
                columns:
                    [[{
                        field: 'ck',
                        checkbox: true
                    }, {

                        field: 'id',
                        title: '编号',
                        width: 50,
                        height: 50,
                        halign: 'center',
                        sortable: true,
                        align: 'center'
                    }, {

                        field: 'emplyName',
                        title: '市场负责人',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        sortable: true,
                        align: 'center'
                    }, {
                        field: 'name',
                        title: '公司名称',
                        width: 250,
                        height: 50,
                        halign: 'center',
                        align: 'center',

                    }, {//id name abbreviation emplyName  contacts  contactsphone industry  address  level  equipment
                        field: 'abbreviation',
                        title: '公司简称',
                        width: 120,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'contacts',
                        title: '企业对接人',
                        width: 120,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'contactsphone',
                        title: '对接人联系方式',
                        width: 120,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'industry',
                        title: '所属行业',
                        width: 150,
                        height: 50,
                        halign: 'center',
                        align: 'center',
                    }, {
                        field: 'address',
                        title: '企业地址',
                        width: 300,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'level',
                        title: '企业规模',
                        width: 80,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'equipment',
                        title: '设备数量',
                        width: 80,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {//plandate  actualdate contractstatus  launchstatus  createtime remarks

                        field: 'plandate',
                        title: '计划投放时间',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        align: 'center',
                        formatter: format
                    }, {
                        field: 'actualdate',
                        title: '实际投放时间',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        align: 'center',
                        formatter: format
                    }, {
                        field: 'contractstatus',
                        title: '签约状态',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        align: 'center',

                    }, {
                        field: 'launchstatus',
                        title: '投放状态',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }, {
                        field: 'createtime',
                        title: '创建日期',
                        width: 100,
                        height: 50,
                        halign: 'center',
                        align: 'center',
                        formatter: format
                    }, {
                        field: 'remarks',
                        title: '备注',
                        width: 150,
                        height: 50,
                        halign: 'center',
                        align: 'center'
                    }
                    ]],
                url: pageConfig.getAction,
                pagination: true,
                pageSize: 30,
                pageList: [30, 35,40],
                sortName: 'id',
                sortOrder: 'desc',
                toolbar: '#tool'
            });
            $("#formdialog").dialog({
                width: 300,
                height: 200,
                closed: true,
                modal: true,
                buttons: '#btns'
            });
        });
        var pageConfig = {
            type: null,
            getAction: '@Url.Action("Get2")',
            saveAction: '@Url.Action("Save")',
            delAction: '@Url.Action("Delete")',
            modifyAction: '@Url.Action("Modify1")',
            getOneAction: '@Url.Action("GetOnlyOne")',
        };

        //点击保存按钮   
        function save() {
            var rows = $("#data").datagrid("getSelections");
            var data;
            data = {
                id: $("#formdialog input[name='id']").val(),
                launchstatus: $("#launchstatus").combobox('getValue'),
            };
           
            $.ajax({
                url: '/BigCustomer/Modify1',
                dataType: "json",
                data: data,
                type: "POST",
                beforeSend: function () {
                    $.messager.progress({ title: "执行中", text: "" });
                },
                success: function (data) {
                    $.messager.alert("成功", data.msg, "info");
                },
                error: function (data) {
                    $.messager.alert("警告", "系统故障", "error", "")
                },
                complete: function () {

                    complete();
                }
            });
        }
        function searchData() {
            $("#data").datagrid('load', {
                companyName: $("#txtName").val(),
            });

        }
        //弹出框 
        function alertFormDialog() {

            $("#formdialog form").form("reset");
            var rows = $("#data").datagrid("getSelections");
            if (rows.length != 1) {
                $.messager.alert("提示", "修改时必须且只能选中一条记录！", "info");
            }
            else {
                $("#formdialog").dialog("open");
                $("#formdialog").dialog("setTitle", "修改");
                $.ajax({
                    async: false,
                    url: pageConfig.getOneAction + "?id=" + rows[0].id,
                    dataType: "json",
                    type: "POST",
                    success: function (data) {
                        alert(data.id);
                        $("#formdialog input[name='id']").val(data.id);
                        $("#launchstatus").combobox('setValue', data.launchstatus);
                    }
                });
            }
        }

        function closeDptDialog() {
            $("#formdialog").dialog("close")
        }
 

        function before() {
            $.messager.progress({ title: "执行中", text: "" });
        }
        function success(data) {
            $.messager.alert("成功", data.msg, "info");
        }
        function error() {

            $.messager.alert("警告", "系统故障", "error", "")
        }
        function complete() {   
            $("#data").datagrid("load");
            $.messager.progress("close");
            $("#formdialog").dialog("close");
        }
    </script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%">
    <div data-options="region:'center'">
        <table id="data"></table>
        <div id="tool" style="padding: 10px;">
            <div style="margin-bottom: 10px;">
                <div style="margin-bottom: 10px;">
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                    @*<a class="easyui-linkbutton" iconcls="icon-add" style="width: 150px; height: 50px;" onclick="alertFormDialog(1)">添加点位信息</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                    <a class="easyui-linkbutton" iconcls="icon-edit" style="width: 150px; height: 50px;" onclick="alertFormDialog(2)">修改点位信息</a> &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp *@
                    <a class="easyui-linkbutton" iconcls="icon-remove" style="width: 150px; height: 50px;" onclick="alertFormDialog()">修改投放状态</a>
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                   公司名称：<input id="txtName" style="width: 180px; height: 25px; margin-top: 15px" type="text" onchange="searchData()" />
                    &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                <a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData()">查询</a>
                </div>
            </div>
        </div>
    </div>

    <div id="formdialog">
        @using (Ajax.BeginForm(new AjaxOptions
        {
            OnBegin = "before",
            OnComplete = "complete",
            OnSuccess = "success",
            OnFailure = "error",
            HttpMethod = "Post"
        }))
        {
            <div class="dialog-table">
                <form id="fm" method="post">
                    @Html.HiddenFor(x => x.id)
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tk_table">

                        <tr>
                            <td>点位状态：</td>
                            <td class="white-tr">
                                <select class="easyui-combobox" id="launchstatus" style="width: 150px">
                                    <option value="1">已投放</option>
                                    <option value="2">撤架</option>
                                    <option value="0">未投放</option>
                                </select>
                        </tr>

                    </table>
                </form>
            </div>
        }
    </div>

    <div id="btns">
        <div style="margin-bottom: 10px">
            <a class="easyui-linkbutton" iconcls="icon-redo" onclick="closeDptDialog()">取消</a>
            <a class="easyui-linkbutton" iconcls="icon-add" onclick="save()">保存</a>
        </div>
    </div>

</body>
</html>
